  <?php 
require_once("nav.php");
//用户id是通过GET方法提交的   
   //根据用户id从数据库中查询用户的所有信息
   $id = $_GET['id'];  
   $sql = "select * from users where uid={$id}";   
   $result = mysql_query($sql) or die('查询失败！'.mysql_error());   
   $row = mysql_fetch_assoc($result);
   //var_dump($row);   
   $uname = $row['uname'];
   $password=$row['password'];
   $gender = $row['gender'];
   $birthdate = $row['birthdate'];
   $hobby = $row['hobby'];
   $degree = $row['degree'];
   $intro = $row['intro'];
   $pic = UserPhotoPath.$row['pic'];    
  //将查询结果显示在表单中
 ?>
       <div class="col-sm-9 col-md-10">
       <h2 class ="text-center">用户修改</h2>
<form method="post"  action="userUpdate.php"  enctype="multipart/form-data" class="form-horizontal">
<input type="hidden" name="id" value="<?php echo $id;?>"></input>

<!-- 用户名 -->
<div class="form-group">
        <label for="uname" class="col-md-2 col-xs-3 control-label">用户名</label>
        <div class="col-md-10 col-xs-9">
          <input type="text" class="form-control" id="uname" placeholder="用户名" name="uname" value="<?php echo  $uname; ?>">
        </div>
        </div>

<!-- 密码 -->
<div class="form-group">
        <label for="password" class="col-md-2 col-xs-3 control-label">密码</label>
        <div class="col-md-10 col-xs-9">
          <input type="password" class="form-control" id="password" placeholder="密码" name="password" value="<?php echo  $password; ?>">
        </div>
        </div>


<!-- 性别 -->

<div class="form-group">
          <label class="col-md-2 control-label">性别</label>
          <div class="col-md-2">
             <label class="radio-inline">
                <input name="gender" type="radio" value="0" <?php 
                if( $gender==0) {echo 'checked';}  
                 ?>>男
             </label>
             <label class="radio-inline">
                <input name="gender" type="radio" value="1" <?php if( $gender==1) {echo 'checked';}  
                 ?>>女
             </label>
          </div>
          </div>  


<!-- 生日 -->
<div class="form-group">
        <label for="birthdate" class="col-md-2 col-xs-3 control-label">生日</label>
        <div class="col-md-10 col-xs-9">
          <input type="date" class="form-control" id="birthdate" placeholder="生日" name="birthdate" value="<?php echo  $birthdate; ?>">
        </div>
        </div>




<!-- 爱好 -->
<div class="form-group">
<label class="col-md-2 col-xs-3 control-label" for="hobby">爱好</label>
<div class="col-md-10 col-xs-9">
  <label class="checkbox-inline">
  <input type="checkbox" name="hobby[]" id="hobby" value="旅游"<?php  
  if(strstr($hobby,'旅游')){echo 'checked';} ?>>旅游 
</label>
<label class="checkbox-inline">
  <input type="checkbox" name="inlineRadioOptions" id="hobby" value="登山" <?php  
  if(strstr($hobby,'登山')){echo 'checked';} ?>>登山 
</label>
<label class="checkbox-inline">
  <input type="checkbox" name="inlineRadioOptions" id="hobby" value="健身"<?php  
  if(strstr($hobby,'健身')){echo 'checked';} ?>>健身 
</label>
<label class="checkbox-inline">
  <input type="checkbox" name="inlineRadioOptions" id="hobby" value="上网"<?php  
  if(strstr($hobby,'上网')){echo 'checked';} ?>>上网 
</label>
<label class="checkbox-inline">
  <input type="checkbox" name="inlineRadioOptions" id="hobby" value="游泳"<?php  
  if(strstr($hobby,'游泳')){echo 'checked';} ?>>游泳 
</label>
</div>
</div>


<!-- 学历 -->
<div class="form-group">
            <label class="col-md-2 col-xs-3 control-label">学历</label>
             <div class="col-md-10 col-xs-9">
                <select name="degree" class="form-control">
                  <option value="0">请选择</option>
                  <option value="1">高中</option> 
                  <option value="2">大学</option>
                  <option value="3">研究生</option>  
                  <option value="4">博士生</option>  
                </select>
                </div>
                </div>



<!-- 自我介绍 -->
<div class="form-group">
        <label for="intro" class="col-md-2 col-xs-3 control-label">自我介绍</label>
        <div class="col-md-10 col-xs-9">
          <input type="text" class="form-control" id="intro" placeholder="自我介绍" name="intro" value="<?php echo  $intro; ?>">
        </div>
        </div>

<!-- 头像 -->
<div class="from-group">
             <label for ="pic"class="col-md-2 col-xs-3 control-label" >头像</label>
             <divclass="col-md-10 col-xs-9"></div>
            <input name="pic" type="file" id="pic"></input>
            </div>
             </div>





<!-- 按钮 -->
<div class="from-group">
             <label class="col-xs-3 "></label>
            <div class="col-md-10 col-xs-9 col-xs-offset-2 ">
            <input  type="submit" value="更新"></input>
            <input  type="reset" value="重置"></input>
</div>
</div>








</form>
      </div>






       <?php 
require_once('footer.php');
 ?>
